<script setup>
import { ref, watch } from "vue";
import axios from "axios";

defineProps({
  msg: String,
});

const count = ref(0);
const value1 = ref(false);
const input = ref("");
watch(value1, (newValue, oldValue) => {
  if (newValue) {
    console.log(document.querySelector("html").classList);
    document.querySelector("html").classList.add("dark");
  } else {
    document.querySelector("html").classList.remove("dark");
  }
});
const handleCommand = (command) => {
  // ElMessage.success(`click on item ${command}`)
  if (command === "exit") {
    window.location.href = "/login";
  }
}
</script>

<template>
  <div class="common-layout">
    <el-container>
      <el-aside style="background-color: rgba(255,0,0,0.2) !important;" class="hidden" width="200px">
        <el-menu default-active="1" class="el-menu-vertical-demo"
          style="height: 100vh; background-color: rgba(0,0,0,0);">
          <RouterLink to="/home/index" style="text-decoration: none">
            <el-menu-item index="1">
              <el-icon>
                <House />
              </el-icon>
              <span>首页</span>
            </el-menu-item>
          </RouterLink>

          <el-sub-menu index="2">
            <template #title>
              <el-icon>
                <location />
              </el-icon>
              <span>功能菜单</span>
            </template>
            <RouterLink to="/home/user-control" style="text-decoration: none">
              <el-menu-item index="2-1">用户管理</el-menu-item>
            </RouterLink>
            <RouterLink to="/home/file-control" style="text-decoration: none">
              <el-menu-item index="2-2">文件管理</el-menu-item>
            </RouterLink>
          </el-sub-menu>
        </el-menu>
      </el-aside>
      <el-container>
        <el-header style="
            display: flex;
            flex-direction: row;
            padding-top: 10px;
            padding-bottom: 10px;
            justify-content: space-between;
            height: 80px;
          ">
          <div style="display: flex; align-items: center">
            <el-input v-model="input" style="width: 240px" placeholder="Please input" />
            <el-icon :size="20" :color="'gray'" style="margin-left: 10px">
              <Search />
            </el-icon>
            <!-- <icon-drawer /> -->
          </div>
          <div style="display: flex; align-items: center">
            <el-switch v-model="value1" />
            <el-icon :size="20" :color="'gray'" style="margin-left: 10px">
              <Promotion />
            </el-icon>
            <el-dropdown @command="handleCommand" style="margin-left: 10px">
              <span class="el-dropdown-link">
                用户名<el-icon class="el-icon--right"><arrow-down /></el-icon>
              </span>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item command="cld">日历</el-dropdown-item>
                  <el-dropdown-item command="exit">退出</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </div>
        </el-header>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style scoped>
.read-the-docs {
  color: #888;
}

@media only screen and (max-width: 1000px) {
  .hidden {
    display: none;
  }
}
</style>
